package org.haier.aws.lambda;

import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.LambdaLogger;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import com.amazonaws.services.lambda.runtime.events.DynamodbEvent;

import java.util.List;

/**
 * @author: SongKun
 * @date: 2021/5/6
 */
public class DynamoDBApp implements RequestHandler<DynamodbEvent, String> {

    @Override
    public String handleRequest(DynamodbEvent event, Context context) {
        LambdaLogger logger = context.getLogger();
        List<DynamodbEvent.DynamodbStreamRecord> records = event.getRecords();
        for (DynamodbEvent.DynamodbStreamRecord record : records) {
            logger.log("EventId:" + record.getEventID());
            logger.log("EventName:" + record.getEventName());
            logger.log("DynamoDB:" + record.getDynamodb().toString());
        }
        // 调用一个sns API
        //
        return "200 OK";

    }
}
